/*
 * GNU GENERAL PUBLIC LICENSE, Version 3, 29 June 2007
 */
package com.google.gwt.gwtpages.client.event;


import java.util.List;

import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.gwtpages.client.message.GWTMessage;

/**
 * Event representing a change in notification messages
 * 
 * @author Joe Hudson
 */
public class MessageChangeEvent extends
		GwtEvent<MessageChangeEvent.MessageChangeHandler> {

	public interface MessageChangeHandler extends EventHandler {
		/**
		 * Event handler for messages changed event
		 * 
		 * @param messages
		 *            the messages
		 */
		void onMessagesChanged(List<GWTMessage> messages);
	}

	private List<GWTMessage> messages;

	public MessageChangeEvent(List<GWTMessage> messages) {
		this.messages = messages;
	}

	public static final GwtEvent.Type<MessageChangeEvent.MessageChangeHandler> TYPE = new GwtEvent.Type<MessageChangeHandler>();

	@Override
	public com.google.gwt.event.shared.GwtEvent.Type<MessageChangeHandler> getAssociatedType() {
		return TYPE;
	}

	@Override
	protected void dispatch(MessageChangeEvent.MessageChangeHandler handler) {
		handler.onMessagesChanged(messages);
	}
}